package br.com.registrofinancas.util;

import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;

import android.widget.TextView;
import br.com.registrofinancas.R;
import br.com.registrofinancas.view.FinancasActivity;

public class CalendarUtilNavegavacaoMes {
	
	public static GregorianCalendar setPreviousMonth(GregorianCalendar mes) {
		if (mes.get( GregorianCalendar.MONTH ) == mes.getActualMinimum( GregorianCalendar.MONTH )) {
			mes.set( ( mes.get( GregorianCalendar.YEAR ) - 1 ), mes.getActualMaximum( GregorianCalendar.MONTH ), 1) ;
		}
		else {
			mes.set( GregorianCalendar.MONTH, mes.get( GregorianCalendar.MONTH ) - 1 ) ;
		}
		
		return mes;

	}
	
	public static GregorianCalendar setNextMonth(GregorianCalendar mes) {
		if (mes.get( GregorianCalendar.MONTH ) == mes.getActualMaximum( GregorianCalendar.MONTH )) {
			mes.set( ( mes.get( GregorianCalendar.YEAR ) + 1 ),	mes.getActualMinimum( GregorianCalendar.MONTH ), 1) ;
		}
		else {
			mes.set( GregorianCalendar.MONTH, mes.get( GregorianCalendar.MONTH ) + 1) ;
		}
		
		return mes;
		
	}
	
	public static void setMes(FinancasActivity financasActivity, GregorianCalendar mes, TextView mesAnoHeaderNavegacao, SimpleDateFormat formatoMesAnoHeaderNavegacao){
		mesAnoHeaderNavegacao.setText(formatoMesAnoHeaderNavegacao.format(mes.getTime()).toUpperCase());
	}
	
}
